import pygetwindow as gw
import pyautogui

def find_window():
    target_window_title = "跳一跳"
    target_window = gw.getWindowsWithTitle(target_window_title)
    if target_window:
        print(f"找到窗口：{target_window_title}")
        window = target_window[0]
        return window
    else:
        print("未找到该窗口！")

def take_screenshot(window):
    left = window.left + 13
    top = window.top + 5
    width = window.width - 15
    height = window.height - 15

    screenshot = pyautogui.screenshot(region=(left, top, width, height))
    print(left,top,width,height)
    screenshot.save("1.3.png")
    print("截图已保存为 1.png")


if __name__ == "__main__":
    window = find_window()
    if window:
        take_screenshot(window)